package vip.xiaonuo.facedoor.modular.visitor.controller.event;


import java.util.ArrayList;

public class publisher {

    public static ArrayList<Listener> list = new ArrayList<>();

    public static void publish(Event event) {
        for (Listener listener : list) {
            listener.onEvent(event);
        }
    }

    public static void addListener(Listener listener) {
        list.add(listener);
    }

    public static void main(String[] args) {
        publisher.addListener(new DoorEventListener());
        Event event = new Event();
        event.setData("dada");
        publisher.publish(event);
    }
}
